/**
 * Copyright (c) 2009 blurredVision
 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
 * associated documentation files (the "Software"), to deal in the Software without restriction, 
 * including without limitation the rights to use, copy, modify, merge, publish, distribute, 
 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all copies or 
 * substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT 
 * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 
 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT 
 * OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */
#ifndef __DX_TRUETYPEFONT_H__
#define __DX_TRUETYPEFONT_H__

#pragma once
#include "IFont.h"
#include "DXResource.h"

#include <d3dx9.h>

namespace directx {

#define NUMCHARS 256

class TrueTypeFont :
	public IFont, DXResource
{
public:
	TrueTypeFont(void);
	virtual ~TrueTypeFont(void);

	// Loads a bitmap font
	virtual bool load(const std::string &image, int size, int style = FONT_NORMAL);

	// Print a text at the specified position
	virtual void print(const std::string &str, int x, int y, int z=0, int align = FONT_LEFT, int width = 0, int heigth = 0, const math::Vector4 &color = math::Vector4(1,1,1,1));

	void reset();
	void release();

	virtual int getLength(const std::string &str);

	//void setColor(const math::Vector4 &_vCol);
	//void setColor(float r, float g, float b, float a);
protected:
	void calcCharSize();
private:
	std::string sFilename;

	RECT font_rect;
	LPD3DXFONT  pFont;
	//D3DCOLOR d3dColor;
	int charwidth[NUMCHARS];
};

} // namespace

#endif
